import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 宿舍信息 */
export interface itories {
          id: number; // 编号
          buildingId?: number; // 楼栋
          roomNo?: string; // 门牌号
          roomType: number; // 宿舍类型：'单人间','双人间','四人间','六人间'
          price?: number; // 房价
          currentOccupancy?: number; // 入住人数
          status: number; // 状态:'空闲','已满','维修中'
  }

// 宿舍 API
export const itoriesApi = {
  // 查询宿舍分页
  getitoriesPage: async (params: any) => {
    return await request.get({ url: `/dorm/itories/page`, params })
  },

  // 查询宿舍详情
  getitories: async (id: number) => {
    return await request.get({ url: `/dorm/itories/get?id=` + id })
  },

  // 新增宿舍
  createitories: async (data: itories) => {
    return await request.post({ url: `/dorm/itories/create`, data })
  },

  // 修改宿舍
  updateitories: async (data: itories) => {
    return await request.put({ url: `/dorm/itories/update`, data })
  },

  // 删除宿舍
  deleteitories: async (id: number) => {
    return await request.delete({ url: `/dorm/itories/delete?id=` + id })
  },

  /** 批量删除宿舍 */
  deleteitoriesList: async (ids: number[]) => {
    return await request.delete({ url: `/dorm/itories/delete-list?ids=${ids.join(',')}` })
  },

  // 导出宿舍 Excel
  exportitories: async (params) => {
    return await request.download({ url: `/dorm/itories/export-excel`, params })
  },
    // 获取所有楼栋（带s的版本，兼容GatewaysForm.vue的使用）

  // 获取所有宿舍（带s的版本，兼容UsersForm.vue的使用）
  getDormitoriesAll: async () => {
    return await request.get({ url: `/dorm/itories/all` })
  },
}
